%Figure 4: Cost in different phases with different demands
%Assume that only provider 3, provide VMs for 3 class
averageReservationPrice = 1/3*(reservationPriceUnit(4,1)+reservationPriceUnit(4,2)+reservationPriceUnit(4,3));
averageUtilizationPrice = 1/3*(utilizationPriceUnit(4,1)+utilizationPriceUnit(4,2)+utilizationPriceUnit(4,3));
averageOndemandPrice = 1/3*(ondemandPriceUnit(4,1)+ondemandPriceUnit(4,2)+ondemandPriceUnit(4,3));

requiredVMsX = 1:50;
reservedVMs = ones(1,50)*29;
reservationCostY = averageReservationPrice*reservedVMs;
plot(requiredVMsX, reservationCostY);
hold on

utilizationCostY = min(requiredVMsX,reservedVMs)*averageUtilizationPrice;
plot(requiredVMsX, utilizationCostY, 'red');
hold on

ondemandCostY = max(requiredVMsX - reservedVMs, 0)*averageOndemandPrice;
plot(requiredVMsX, ondemandCostY);
hold on

oversubscribedCostY = max(reservedVMs - requiredVMsX, 0)*averageReservationPrice;
plot(requiredVMsX, oversubscribedCostY, 'green');
hold on

totalCost = reservationCostY + utilizationCostY + ondemandCostY;
plot(requiredVMsX, totalCost);
